package com.mask.mr.number;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * ClassName NumberMapper
 * Create by hx
 * Date 2021/9/29 9:48 上午
 */

public class NumberMapper extends Mapper<LongWritable, Text,Text, IntWritable> {
    public void map(LongWritable key, Text value,
                    Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        String lineString = value.toString();
        String[] words = lineString.split(",");
        for(String word: words) {
            if(!word.startsWith("2")) {
                context.write(new Text(word), new IntWritable(1));
            }
        }
    }
}


